From 9133c58b8d91b6e58d81e7d285c310202ef91ab7 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 2 Mar 2004 20:05:08 +0000 Subject: [PATCH] Don't update the save folder combo if we are already switching folders; 2004-03-02 Federico Mena Quintero * gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_current_folder): Don't update the save folder combo if we are already switching folders; based on a patch by Jonathan Blandford. * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): Handle failure to insert the path. Based on a patch by Morten Welinder attached to bug #135380. * tests/testfilechooser.c (extra_widget_create): Add a bunch of buttons to test various things. --- ChangeLog | 14 ++++++++ ChangeLog.pre-2-10 | 14 ++++++++ ChangeLog.pre-2-4 | 14 ++++++++ ChangeLog.pre-2-6 | 14 ++++++++ ChangeLog.pre-2-8 | 14 ++++++++ gtk/gtkfilechooserdefault.c | 24 ++++++++++---- tests/testfilechooser.c | 66 ++++++++++++++++++++++++++++++++++--- 7 files changed, 149 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77d7eb34e1..8f45ea8b47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-03-02 Federico Mena Quintero + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_set_current_folder): Don't update the + save folder combo if we are already switching folders; based on a + patch by Jonathan Blandford. + + * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): + Handle failure to insert the path. Based on a patch by Morten + Welinder attached to bug #135380. + + * tests/testfilechooser.c (extra_widget_create): Add a bunch of + buttons to test various things. + Tue Mar 2 20:59:23 2004 Matthias Clasen * tests/Makefile.am: Add testentrycompletion. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 77d7eb34e1..8f45ea8b47 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +2004-03-02 Federico Mena Quintero + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_set_current_folder): Don't update the + save folder combo if we are already switching folders; based on a + patch by Jonathan Blandford. + + * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): + Handle failure to insert the path. Based on a patch by Morten + Welinder attached to bug #135380. + + * tests/testfilechooser.c (extra_widget_create): Add a bunch of + buttons to test various things. + Tue Mar 2 20:59:23 2004 Matthias Clasen * tests/Makefile.am: Add testentrycompletion. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 77d7eb34e1..8f45ea8b47 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +2004-03-02 Federico Mena Quintero + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_set_current_folder): Don't update the + save folder combo if we are already switching folders; based on a + patch by Jonathan Blandford. + + * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): + Handle failure to insert the path. Based on a patch by Morten + Welinder attached to bug #135380. + + * tests/testfilechooser.c (extra_widget_create): Add a bunch of + buttons to test various things. + Tue Mar 2 20:59:23 2004 Matthias Clasen * tests/Makefile.am: Add testentrycompletion. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 77d7eb34e1..8f45ea8b47 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +2004-03-02 Federico Mena Quintero + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_set_current_folder): Don't update the + save folder combo if we are already switching folders; based on a + patch by Jonathan Blandford. + + * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): + Handle failure to insert the path. Based on a patch by Morten + Welinder attached to bug #135380. + + * tests/testfilechooser.c (extra_widget_create): Add a bunch of + buttons to test various things. + Tue Mar 2 20:59:23 2004 Matthias Clasen * tests/Makefile.am: Add testentrycompletion. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 77d7eb34e1..8f45ea8b47 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +2004-03-02 Federico Mena Quintero + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_set_current_folder): Don't update the + save folder combo if we are already switching folders; based on a + patch by Jonathan Blandford. + + * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): + Handle failure to insert the path. Based on a patch by Morten + Welinder attached to bug #135380. + + * tests/testfilechooser.c (extra_widget_create): Add a bunch of + buttons to test various things. + Tue Mar 2 20:59:23 2004 Matthias Clasen * tests/Makefile.am: Add testentrycompletion. diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 173830cf27..de7beb07d3 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -958,7 +958,7 @@ shortcuts_remove_rows (GtkFileChooserDefault *impl, gtk_tree_path_free (path); } -/* Used from shortcuts_remove_rows() */ +/* Used from shortcuts_remove_rows() in shortcuts_add_volumes() */ static void volume_remove_cb (GtkFileChooserDefault *impl, gpointer data) { @@ -1058,9 +1058,12 @@ static void shortcuts_add_current_folder (GtkFileChooserDefault *impl) { int pos; + gboolean success; g_assert (!impl->shortcuts_current_folder_active); + success = TRUE; + pos = shortcut_find_position (impl, impl->current_folder); if (pos == -1) { @@ -1080,22 +1083,26 @@ shortcuts_add_current_folder (GtkFileChooserDefault *impl) if (strcmp (gtk_file_path_get_string (base_path), gtk_file_path_get_string (impl->current_folder)) == 0) { - shortcuts_insert_path (impl, pos, TRUE, volume, NULL, NULL, FALSE, NULL); + success = shortcuts_insert_path (impl, pos, TRUE, volume, NULL, NULL, FALSE, NULL); impl->shortcuts_current_folder_is_volume = TRUE; } else { gtk_file_system_volume_free (impl->file_system, volume); - shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, NULL); + success = shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, NULL); impl->shortcuts_current_folder_is_volume = FALSE; } gtk_file_path_free (base_path); - impl->shortcuts_current_folder_active = TRUE; + if (!success) + shortcuts_remove_rows (impl, pos - 1, 1, NULL); /* remove the separator */ + + impl->shortcuts_current_folder_active = success; } - gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos); + if (success) + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos); } /* Used from shortcuts_remove_rows() in shortcuts_update_current_folder() */ @@ -2838,14 +2845,18 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser, /* Change the current folder label */ gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, NULL); - /* Update the folder tree */ + /* Update the widgets that may trigger a folder chnage themselves */ if (!impl->changing_folder) { impl->changing_folder = TRUE; + set_tree_model (impl, impl->current_folder); _gtk_file_system_model_path_do (GTK_FILE_SYSTEM_MODEL (impl->browse_directories_model), path, expand_and_select_func, impl); + + shortcuts_update_current_folder (impl); + impl->changing_folder = FALSE; } @@ -2855,7 +2866,6 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser, /* Refresh controls */ shortcuts_unselect_all (impl); - shortcuts_update_current_folder (impl); g_signal_emit_by_name (impl, "current-folder-changed", 0); diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index 0beb08cad9..3cccdc6779 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -296,6 +296,66 @@ update_preview_cb (GtkFileChooser *chooser) gtk_file_chooser_set_preview_widget_active (chooser, have_preview); } +static void +set_folder_nonexistent_cb (GtkButton *button, + GtkFileChooser *chooser) +{ + gtk_file_chooser_set_current_folder (chooser, "/nonexistent"); +} + +static void +set_folder_existing_nonexistent_cb (GtkButton *button, + GtkFileChooser *chooser) +{ + gtk_file_chooser_set_current_folder (chooser, "/usr/nonexistent"); +} + +static void +set_filename_nonexistent_cb (GtkButton *button, + GtkFileChooser *chooser) +{ + gtk_file_chooser_set_filename (chooser, "/nonexistent"); +} + +static void +set_filename_existing_nonexistent_cb (GtkButton *button, + GtkFileChooser *chooser) +{ + gtk_file_chooser_set_filename (chooser, "/usr/nonexistent"); +} + +static GtkWidget * +extra_widget_create (GtkFileChooser *chooser) +{ + GtkWidget *box; + GtkWidget *widget; + + box = gtk_vbox_new (FALSE, 6); + + widget = gtk_button_new_with_label ("set_current_folder (\"/nonexistent\")"); + g_signal_connect (widget, "clicked", + G_CALLBACK (set_folder_nonexistent_cb), chooser); + gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); + + widget = gtk_button_new_with_label ("set_current_folder (\"/usr/nonexistent\""); + g_signal_connect (widget, "clicked", + G_CALLBACK (set_folder_existing_nonexistent_cb), chooser); + gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); + + widget = gtk_button_new_with_label ("set_filename (\"/nonexistent\""); + g_signal_connect (widget, "clicked", + G_CALLBACK (set_filename_nonexistent_cb), chooser); + gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); + + widget = gtk_button_new_with_label ("set_filename (\"/usr/nonexistent\""); + g_signal_connect (widget, "clicked", + G_CALLBACK (set_filename_existing_nonexistent_cb), chooser); + gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); + + gtk_widget_show_all (box); + return box; +} + int main (int argc, char **argv) { @@ -306,7 +366,6 @@ main (int argc, char **argv) GtkWidget *prop_editor; GtkFileFilter *filter; GtkWidget *preview_vbox; - GtkWidget *extra; int i; gtk_init (&argc, &argv); @@ -397,9 +456,8 @@ main (int argc, char **argv) G_CALLBACK (update_preview_cb), NULL); /* Extra widget */ - extra = gtk_check_button_new_with_mnemonic ("Lar_t whoever asks about this button"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extra), TRUE); - // gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), extra); + + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), extra_widget_create (GTK_FILE_CHOOSER (dialog))); /* Shortcuts */ -- 2.30.2